﻿#pragma once

#include <QTextEdit>
#include <QTextBlock>
#include "iQTextCursor.h"
#include "NotePadConfig.h"

class iQTextEdit :public QTextEdit{
public:
	ViewMode view_mode;
	iQTextEdit() :QTextEdit() {
		// 连接 positionChanged() 信号到槽函数
		connect(this, &QTextEdit::cursorPositionChanged, this, &iQTextEdit::handleCursorPositionChanged);
	}

	void setMarkdown(const QString& markdown);
	iQTextCursor textCursor() const;

	void keyPressEvent(QKeyEvent* e) override;
	
protected:
	int oldLineNumber = 0;
private:
	QTextCursor& myInsertText(QString& content, QTextCursor& textCursor, ViewMode& mode);
private slots:
	//控制光标位置改变时的操作
	void handleCursorPositionChanged();

	

};